#include "test.h"
//定义函数指针 声明回调函数
typedef void (*callback_t)(double current,double total);

double total = 1024.0;
double speed = 1.0;

void DownLoad(callback_t cb)
{
    double current = 0;
    printf("开始下载数据，请耐心等待...\n");
    while(current <= total)
    {
        //下载数据
        cb(current,total);
        usleep(10000);
        current += speed;
    }
    printf("\ndownload %.2lfMB done\n",total);
}

void UpLoad(callback_t cb)
{
    double current = 0;
    printf("开始上传数据，请耐心等待...\n");
    while(current <= total)
    {
        //上传数据
        cb(current,total);
        usleep(10000);
        current += speed;
    }
    printf("\ndownload %.2lfMB done\n",total);
}


int main()
{
    DownLoad(test2);
    UpLoad(test2);
    return 0;
}
